package com.caseProcess.service.impl;

import com.caseProcess.entity.CaseProcInfo;
import com.caseProcess.entity.Urging;
import com.caseProcess.mapper.UrgingDao;
import com.caseProcess.service.CaseProcInfoService;
import com.caseProcess.service.UrgingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author duzq
 * @date 2020/11/15 15:42
 **/
@Service
public class UrgingServiceImpl implements UrgingService {

    @Autowired
    private UrgingDao urgingDao;

    @Resource
    private CaseProcInfoService caseProcInfoService;

    @Override
    @Transactional(rollbackFor = Exception.class)
    public int insert(Urging urging) throws Exception{
        CaseProcInfo caseProcInfo=new CaseProcInfo();
        caseProcInfo.setProcessId(urging.getCaseProcInfo().getProcessId());
        caseProcInfo.setUrging(true);
        caseProcInfo.setProcTatus(-1);
        try {
            caseProcInfoService.update(caseProcInfo);//修改分配过程
            return urgingDao.insert(urging);
        }catch (Exception e){
            e.printStackTrace();
            throw e;
        }

    }

    @Override
    public int update(Urging urging) {
        return urgingDao.update(urging);
    }

    @Override
    public int delete(Urging urging) {
        return urgingDao.delete(urging);
    }

    @Override
    public List<Urging> selectUrgings(Urging urging) {
        return urgingDao.selectUrgings(urging);
    }

    @Override
    public List<Urging> getUrgingInfo(String urgingId) {
        return urgingDao.getUrgingInfo(urgingId);
    }
}
